package com.manager.seat.service.impl;

import com.manager.seat.dao.TbTodoListMapper;
import com.manager.seat.model.TbTodoList;
import com.manager.seat.service.TodosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName ToDoListServiceImpl
 * @Description TODO
 * @date 2022/12/18 23:08
 * @Version 1.0
 */
@Service
public class ToDoListServiceImpl implements TodosService {
    @Autowired
    private TbTodoListMapper todoListMapper;
    @Override
    public List<TbTodoList> getAllTodo(String type) {
        List<TbTodoList> todoLists = todoListMapper.getAllTodo(type);
        if(CollectionUtils.isEmpty(todoLists)){
            return Collections.emptyList();
        }
        return todoListMapper.getAllTodo(type);
    }

    @Override
    public TbTodoList getOne(Long id) {
        return todoListMapper.selectByPrimaryKey(id);
    }



    @Override
    public int update(TbTodoList record) {
        return todoListMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int delete(Long id) {
        return todoListMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(TbTodoList record) {
        return todoListMapper.insert(record);
    }
}
